<template>
  <div class="clearfix">
    <div class="clear hei40"></div>
    <div class="con-width-1200 content">
      <div class="public-title clearfix pos-rel">
        <h2 class="pos-rel course">{{ date1.channelNameEn }}</h2>
        <h1 class="pos-abs">{{ date1.channelName }}</h1>
        <!-- <h3 class="pos-abs">{{ date1.title }}</h3> -->
        <div class="catage clearfix pos-abs">
          您所在位置： ><label v-for="(list1, index) in date1.channelList" :key="index" >{{ list1.channelName }} >
          </label> 列表
        </div>
      </div>
      <ul class="article-list rad5 clearfix" v-if="date1.displayForm=='1'">
        <li class="clearfix pos-rel" v-for="(item, index) in date1.ipage.records" :key="index"
          @click="jump(item)" >
          <h1 class="text-wid">{{index + 1}}. {{ item.title }}</h1>
          <span class="intro">
            {{ item.description }}
          </span>
          <span class="data pos-abs">{{ item.releaseDate }}</span>
        </li>
      </ul>

      <Ul class="block-list clearfix" v-else-if="date1.displayForm=='2'">
        <li class="clarfix" v-for="(item,index) in date1.ipage.records" :key="index"  >
<!--        <li class="clarfix" v-for="(item,index) in date1.ipage.records" :key="index" @click="jump(item.id)" >-->
          <div class="con pos-rel clearfix">
            <img class="img" :src=item.titleImg>
            <div class="pos-abs text clearfix">
              <h1>{{item.title}}</h1>
              <span class="desc">{{item.description | ellipsis}}</span>
            </div>
          </div>
        </li>
      </ul>

       <!-- <Ul class="block-list clearfix" v-else-if="date1.displayForm=='3'">
            <li class="clarfix" v-for="(item,index) in date1.ipage.records" :key="index"  >
                &lt;!&ndash;        <li class="clarfix" v-for="(item,index) in date1.ipage.records" :key="index" @click="jump(item.id)" >&ndash;&gt;
                <div class="con pos-rel clearfix">
                    <img class="img" :src=item.titleImg>
                    <div class="pos-abs text clearfix">
                        <h1>{{item.title}}</h1>
                        <span class="desc">{{item.description | ellipsis}}</span>
                    </div>
                </div>
            </li>
        </ul>-->

      <!-- <ul class="article-list rad5 clearfix" v-else>
        <li class="clarfix" v-for="(item,index) in imgList" :key="index">
          <div class="con pos-rel clearfix">
            <img class="img" :src=item.img>
            <div class="pos-abs text clearfix">
              <h1>{{item.name}}</h1>
              <span class="desc">{{item.desc}}</span>
            </div>
          </div>
        </li>
      </ul> -->

    </div>
    <div class="page-list clearfix">
     <!-- <template v-for="count in date1.ipage.pages">
        <a @click="pagination($event, count)" :class="count == date1.ipage.current ? 'focus' : ''" :key="count" >{{ count }}</a>
      </template>-->
      <a @click="pagination($event, 1)" >首页</a>
      <template v-for="count in date1.ipage.pages">
        <a @click="pagination($event, count)" :class="count == date1.ipage.current ? 'focus' : ''" :key="count" v-if="count<=date1.ipage.current+5 && count>date1.ipage.current-5" >{{ count }}</a>
      </template>
      <a @click="pagination($event, date1.ipage.pages)" >尾页</a>
      共{{date1.ipage.pages}}页 跳转至<input style="width: 22px" v-model="pages" @keyup.enter="goPage()">页<a @click="goPage()">go</a>
    </div>
    <div class="clear hei20"></div>
  </div>
</template>

<script>
import _http from "../httpService";

export default {
  name: "HospitalSummedup",
  props: {
    msg: String,
  },
  components: {},
  data() {
    return {
      pageNo: 1,
      pages:1,
      pageSize: 10,
      date1: {
        ipage: {},
        channelName: "",
        channelNameEn: "",
        channelContent: "",
      },
      dataList: [],
      isDisable: false,
      name: "",
      mobile: "",
      content: "",
    };
  },
  filters: {
    ellipsis (value) {
      if (!value) return ''
      if (value.length > 20) {
        return value.slice(0,20) + '...'
      }
      return value
    }
  },
  methods: {
    jump: function(item) {
        if(item.titleColor=='zhuanjiajieshao'){
            this.$router.push({ path: "/listVUE/" + item.id });
        }else{
            this.$router.push({ path: "/Article/" + item.id });
        }
    },

    pagination: function(e, pageNo) {
      // console.log("dddd" + e.target.$el.class)
      this.pageNo = pageNo

      _http
        .get(
          "/content/jcContent/listArticle?channelCode=" +
            this.$route.query.channelCode +
            "&pageNo=" +
            pageNo +
            "&pageSize=" +
            this.pageSize
        )
        .then((resp) => {
          if (resp.data.success) {
            this.date1 = resp.data.result;
          }
        })
        .catch((error) => console.log(error))
        .finally(() => (this.loading = false));
    },
    goPage: function() {
      this.pageNo = this.pages
      _http.get("/content/jcContent/listArticle?channelCode=" +
                      this.$route.query.channelCode +
                      "&pageNo=" +
              this.pages +
                      "&pageSize=" +
                      this.pageSize
              )
              .then((resp) => {
                if (resp.data.success) {
                  this.date1 = resp.data.result;
                }
              })
              .catch((error) => console.log(error))
              .finally(() => (this.loading = false));
    },
  },

  watch: {
    //监听相同路由下参数变化的时候，从而实现异步刷新

   $route() {
      _http
        .get(
          "/content/jcContent/listArticle?channelCode=" +
            this.$route.query.channelCode +
            "&pageNo=" +
            this.pageNo +
            "&pageSize=" +
            this.pageSize
        )
        .then((resp) => {
          if (resp.data.success) {
            this.date1 = resp.data.result;
          }
        })
        .catch((error) => console.log(error))
        .finally(() => (this.loading = false));
    },
    immediate: true,
  },

  created() {
    _http
        .get(
          "/content/jcContent/listArticle?channelCode=" +
            this.$route.query.channelCode +
            "&pageNo=" +
            this.pageNo +
            "&pageSize=" +
            this.pageSize
        )
        .then((resp) => {
          if (resp.data.success) {
            this.date1 = resp.data.result;
          }
        })
        .catch((error) => console.log(error))
        .finally(() => (this.loading = false));
  }
};
</script>
<style lang="scss" scoped>
@import "../assets/css/public.css";
@import "../assets/css/public.scss";
</style>
